package com.taotao.test2;

import java.util.*;

/**
 * @program: test2
 * @ClassName Test
 * @description:
 * @author: wangjin
 * @create: 2023-08-04 09:22
 * @Version 1.0
 **/
public class Test {
    public static void main(String[] args) {
        String[] strs = {"eat", "tea", "tan", "ate", "nat", "bat"};

        Map map = new HashMap<>();


        for (int i = 0; i < strs.length; i++) {
            char[] chars = strs[i].toCharArray();
            Arrays.sort(chars);
           // System.out.println(chars);
            map.put(i, chars);
        }
        Map map1=new HashMap();
        map.forEach((key, value) -> {
            char[] chars = (char[]) value;
            int keys = (int) key;
            for(Object key1:map.keySet()){


                char[] chars1 = (char[]) map.get(key1);

                int keys1 = (int) key1;
                if(chars==chars1 ){

                        List list=new ArrayList();
                        list.add(strs[keys]);
                        list.add(strs[keys1]);
                        map1.put(list.toString(),list);


                }
            }


        });


        map1.forEach((key1, value1) -> {
            System.out.println(value1.toString());
        });

    }
}
